#ifndef CLEANER_H
#define CLEANER_H

#include <QObject>
#include "engine.h"
#include "gui/main_widget.h"
#include "gui/menu_manager.h"
#include "controller.h"
#include "model/player.h"

using namespace anime;

class Cleaner: public QObject
{
    Q_OBJECT

public:
    Cleaner(Engine* _engine,
            MainWidget* _w,
            Controller* _controller)
        :engine(_engine), w(_w), controller(_controller){}
    ~Cleaner(){}

public slots:
    void clean()
    {
        qDebug("Stopping the engine..");
        //engine->PrintState();
        engine->RemoveDrawable(w);
        engine->StopIt();
        while(engine->isRunning());
        Player::DeleteInstance();
        CoreIO::docsManager->save();
    }

private:
    Engine* engine;
    MainWidget* w;
    Controller* controller;
};

#endif // CLEANER_H
